Grayscale correction for correcting brightness and contrast in an image which is captured under an illumination condition such as a condition that a subject is photographed against the light is known, and gamma correction and histogram correction are typical examples of the grayscale correction. With gamma correction and histogram correction, however, as image correction is performed using a fixed coefficient, problems of an image being white by overexposure and an image being black by underexposure arise.
On the other hand, adaptive grayscale correction (adaptive enhancement) in which, in addition to the gray level value of image data, information concerning pixels adjacent to a pixel to be corrected is used to determine correction coefficients has been proposed, and with this technology, correction in accordance with the content of an image can be achieved. The adaptive grayscale correction is disclosed in “Comparison of Retinex Models for Hardware Implementation” by Nosato et al., IEICE technical report, SIS, 2005-16, pp. 19-24 (June, 2005). The adaptive grayscale correction is based on Retinex theory, in which assuming that an input image is represented by a product of illumination light and reflectivity, illumination light is separated from an input image to thereby obtain a reflectivity image as a correction image. Provided that an input image I is represented as an input image I=illumination light L× reflectivity R (correction image), the relationship of R(x, y)=exp {log(I(x,y))−log(L(x,y))} can be achieved. Calculus of variation is used to estimate the illumination light, and a plurality of layers k with a resolution which is ½k that of the original image are generated and calculation for updating the illumination light is repeated starting from a layer with a lower resolution. Here, the calculation for updating the illumination light is performed by using the expression of L(x, y)=L x, y)−μNSD×G(x, y), wherein G(x, y) is a gradient of cost function and μNSD is learning coefficient. Specifically, a processing, in which G(x, y) is first calculated, and μNSD(x, y) is then calculated, and based on these calculation results, L(x, y) is calculated, is repeated.
Further, JP2007-27967A discloses that, when a person photographing mode is selected, an image is captured with the exposure value being set to a value under an appropriate exposure value computed by an AE (Automatic Exposure) detector, and grayscale correction is applied to image data obtained by image capturing by using a γ transform table for increasing the dynamic range of image data which has been subjected to gray level conversion processing, thereby correcting the brightness value of portions of the image with insufficient brightness which are located in the vicinity of the center of the subject.
As described above, problems of an image being white by overexposure and an image being black by underexposure can be prevented by photographing a subject with the exposure value being set under the appropriate exposure value which is set by AE and then adaptively performing grayscale correction with respect to the resulting image data. However, this method, in which the exposure value which is under the appropriate value (hereinafter referred to as an “underexposure value”) is fixed, cannot be applied to various types of images and therefore suffers from a disadvantage that an image desired by a user cannot be obtained.